<!DOCTYPE html>
<html lang='zh-CN'>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

  <title>会员信息管理</title>
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/materialdesignicons.min.css" rel="stylesheet">
  <link href="css/animate.css" rel="stylesheet">
  <link href="css/style.min.css" rel="stylesheet">
  <link href="js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid p-t-15">

  <div class="row">
    <div class="col-md-12">
      <div class="card">
        <div class="card-header"><h4>会员信息</h4></div>
          <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="home">

              <form class="form-inline" method="post" id="searchForm">
                <div class="form-group">
                  <label>会员ID:</label>
                  <input type="text" class="form-control" name="memberId">
                </div>
                <div class="form-group">
                  <label>会员名称:</label>
                  <input type="text" class="form-control" name="memberName">
                </div>
                <div class="form-group">
                  <label>联系电话:</label>
                  <input type="text" class="form-control" name="memberPhone">
                </div>
                <div class="form-group">
                  <label>会员等级:</label>
                  <select name="gradeId" class="form-control">
                    <option value="">全部</option>
                    <option value="3">粉丝</option>
                    <option value="0">合作商家</option>
                    <option value="4">创业VIP</option>
                    <option value="1">联盟商家</option>
                    <option value="2">联盟企业</option>
                  </select>
                </div>
                <div class="form-group">
                  <button class="btn btn-info btn_query btn-round"  type="button" id="searchFormBtn" >查询</button>
                </div>
                <div class="form-group">
                  <button class="btn btn-success btn_query btn-round"  type="button" id="upgradeVIP" >升级'VIP'</button>
                </div>
                <div class="form-group">
                  <button class="btn btn-warning btn_query btn-round"  type="button" id="downgradeFans" >降级'粉丝'</button>
                </div>
              </form>
              <table id="info_data"></table>
            </div>
          </div>
        </div>
      </div>
    </div>

  </div>



<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-table/bootstrap-table.js"></script>
<script type="text/javascript" src="js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="js/zero2one/zero2one.version.js"></script>
<script type="text/javascript" src="js/zero2one/zero2one.core.js"></script>
<script type="text/javascript" src="js/dropzone/min/dropzone.min.js"></script>
<script type="text/javascript" src="js/bootstrapvalidator/dist/js/bootstrapValidator.js"></script>
<!-- bootstrap表单验证插件 -->
<script type="text/javascript" src="js/bootstrap-validator-master/dist/validator.js"></script>
<!-- jquery-form表单提交插件 -->
<script type="text/javascript" src="js/jquery-form/jquery.form.js"></script>
<!-- bootstrap弹出框插件 -->
<script type="text/javascript" src="js/jquery.bootstrap.min.js"></script>
<!-- 表单填充插件 -->
<script type="text/javascript" src="js/jquery-form/jquery.formloader.js"></script>

<script type="text/javascript">

  //设置表头
  var columns = [
    {checkbox: true},
    {field: 'memberId',title: '会员ID'},
    {field: 'memberAccount',title: '会员账号'},
    {field: 'memberName',title: '会员名称'},
    {field: 'gradeId',title: '会员等级',formatter: function (value, row, index) {
        if (value==0){
          return "合作商家"
        }else if(value==1){
          return "联盟商家"
        }else if(value==2){
          return "联盟企业"
        }else if(value==3){
          return "粉丝"
        }else if(value==4){
          return "创业VIP"
        }
      }},
    {field: 'sex',title: '性别',formatter: function (value, row, index) {
        if (value==0){
          return "女"
        }else if(value==1){
          return "男"
        }else {
          return "无"
        }
      }},
    {field: 'memberPhone',title: '联系电话'},
    {field: 'leaderId',title: '上级ID',formatter:function (value) {

        if (value != null){
          return value;
        }else {
          return  "无";
        }
      }},
    {field: 'stationId',title: '站长号',formatter:function (value) {
        if (value != null){
          return  "<button class=\"btn bg-success btn-sm\">"+value+"</button>";
        }else {
          return  "无";
        }
      }},
    {field: 'bypassAccount',title: '站长类型',formatter:function (value) {
        if (value == 0){
          return  "<button class=\"btn bg-success btn-sm\">主站长</button>";
        }else if (value == 1) {
          return  "<button class=\"btn bg-warning btn-sm\">子站长</button>";
        }
      }},
    {field: 'memberEmail',title: '会员邮箱',formatter:function (value) {
            if (value != null){
              return value;
            }else {
              return  "无";
            }
      }},
    {field: 'address',title: '常住地址',formatter:function (value) {
        if (value != null){
          return value;
        }else {
          return  "无";
        }
      }},
    {field: 'birthday',title: '会员生日',formatter:function (value) {
        if (value != null){
          return value;
        }else {
          return  "无";
        }
      }},
    {field: 'registerTime',title: '注册时间',formatter: function (value) {
        return zero2one.dateFormat(value, 'Y-m-d H:i:s')}}
  ];


  //进入主界面加载数据
  zero2one.datagrid("info_data", "/remote/memberInfo/queryInfo",function (params) {
    return $.extend(zero2one.tableInitParam(params), zero2one.form2json("searchForm"));
  }, columns);

  //点击查询按钮重新加载页面数据
  $("#searchFormBtn").click(function () {
    $('#info_data').bootstrapTable('refresh');
  });


  //点击升级VIP按钮
  $("#upgradeVIP").click(function () {
    //获取选中行的数据
    var datas = $('#info_data').bootstrapTable('getSelections');
      if(datas.length ==1){
        $.messager.confirm("温馨提示", "您是否要升级会员等级为VIP?", function () {
          $.post("/remote/memberInfo/upgradeVIP", {"memberId" : datas[0].memberId},function (data) {
                if (data.success) {
                  $.messager.alert("提示", "您已升级VIP成功");
                  setTimeout(function () {
                    window.location.reload();
                  }, 2000);
                } else {
                  $.messager.alert("温馨提示", data.msg)
                }
              },"json");
        })
      }else{
        $.messager.alert("温馨提示", "请选择一条数据操作");

      }

  });

  //点击降级‘粉丝’按钮
  $("#downgradeFans").click(function () {
    //获取选中行的数据
    var datas = $('#info_data').bootstrapTable('getSelections');
    if(datas.length ==1){
      $.messager.confirm("温馨提示", "您是否要升级会员等级为VIP?", function () {
        $.post("/remote/memberInfo/downgradeFans", {"memberId" : datas[0].memberId},function (data) {
          if (data.success) {
            $.messager.alert("提示", "您已降级粉丝成功");
            setTimeout(function () {
              window.location.reload();
            }, 2000);
          } else {
            $.messager.alert("温馨提示", data.msg)
          }
        },"json");
      })
    }else{
      $.messager.alert("温馨提示", "请选择一条数据操作");

    }

  })



</script>
</body>
</html>
